var url = 'http://175.6.20.93:8083/deepvisionx/medical_care/Interface';
//获取接口名
var page = 1;
var api_type = getUrlParam('api_type');
var req_day = getUrlParam('req_day');
$.ajax({
    type:'get',
    url:url,
    data:{
        type:'queryInterfaceName'
    },
    success:function(data){
        var html = '';
        for(var i = 0;i<data.data.length;i++){
            if(data.data[i].api_type == api_type){
                html += '<a class="on">'+data.data[i].api_type+'</a>'
            }else if(api_type == undefined){
                if(i == 0){
                    html += '<a class="on">'+data.data[i].api_type+'</a>'
                }else{
                    html += '<a>'+data.data[i].api_type+'</a>'
                }
            }else{
                html += '<a>'+data.data[i].api_type+'</a>'
            }
        }

        getData(page,data.data[0].api_type);
        $(".jk-menu").append(html).addClass('in');
    },
    error: function(xhr, ajaxOptions, thrownError) {
    }
});

function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
    var r = window.location.search.substr(1).match(reg); //匹配目标参数
    if (r != null) return unescape(r[2]); return null; //返回参数值
}
function replaceParamVal(paramName,replaceWith) {
    var oUrl = this.location.href.toString();
    var re=eval('/('+ paramName+'=)([^&]*)/gi');
    var nUrl = oUrl.replace(re,paramName+'='+replaceWith);
    this.location = nUrl;
    window.location.href=nUrl
}
//获取初始表格方法
function getData(page,api_type,more){
    $.ajax({
        type:'get',
        url:url,
        data:{
            type:'querycountInterface',
            page:page,
            api_type:api_type
        },
        success:function(data){
            var html = '';
            for(var i = 0;i<data.data.length;i++){
                html += '<tr><td>'+data.data[i].req_day+'</td><td>'+data.data[i].sum+'</td><td><a target="_blank" href="chart.html?api_type='+data.data[i].api_type+'&req_day='+data.data[i].req_day+'" class="btn">查看时间曲线图</a></td></tr>';
            }
            if(!more){
                $("table tbody").empty();
            }
            $("table tbody").append(html);
            $(".loading").addClass('out');
            if(data.data.length < 10){
                $('.more').text('没有更多数据了')
            }else{
                $('.more').text('加载更多');
                $('.more').removeAttr('disabled')
            }

        },
        error: function(xhr, ajaxOptions, thrownError) {

        }
    });
}